package cn.gameo2o.service.xzgl.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import cn.gameo2o.dao.xzgl.XiaoZuGuanLiDAO;
import cn.gameo2o.dao.yhgl.YongHuGuanLiDAO;
import cn.gameo2o.pojo.O2o_group;
import cn.gameo2o.service.xzgl.XiaoZuGuanLiService;
import cn.gameo2o.util.PageParam;

/**
 * 游戏小组管理service实现
 * @author 李君
 *
 */
public class XiaoZuGuanLiServiceImpl implements XiaoZuGuanLiService {
	@Autowired
	private XiaoZuGuanLiDAO xzDao;
	
	private YongHuGuanLiDAO yhDao;
	public int addYxxz(O2o_group group, Integer[] ids) {
		xzDao.save(group);
		int groupid = group.getGroupid().intValue();
		for (Integer id : ids) {
			if(yhDao.updatexz(id,groupid)<1){
				return -1;
			}
		}
		return 1;
	}

	public void findYxxz(Map<String, Object> params, PageParam page) {
		// TODO Auto-generated method stub
		Long count = xzDao.count(params);
		page.setTotal(count);
		page.setRows(xzDao.find(params, page.getFirst(), page.getPageSize()));
	}	

	public O2o_group findYxxzById(int id) {
		return xzDao.findById(id);
	}

	public int updateYxxz(O2o_group group) {
		
		return xzDao.update(group);
	}

	public int deleteYxxz(int id) {
		// TODO Auto-generated method stub
		return xzDao.delete(id);
	}
}
